#include "Config.h"
#include "../logs/Logger.h"

using namespace kc_sf;

// ----------------------------------------------------------- //

namespace kc_sf
{
	Config * Config::c_instance = NULL;
	boost::mutex Config::c_guard;
}

// ----------------------------------------------------------- //

Config & Config::getInstance()
{
	if (!c_instance)
	{
		boost::mutex::scoped_lock lock (c_guard);
		if (!c_instance)
			c_instance = new Config ();
	}

	return *c_instance;
}

// ----------------------------------------------------------- //

Config::~Config()
{
	std::cout << "~Config" << std::endl;
	std::cout << "Config PRE c_instance" << std::endl;
	if (c_instance)
		delete c_instance;
	std::cout << "Config POST c_instance" << std::endl;
}

// ----------------------------------------------------------- //

Config::Config()
{
	// wartosci domyslne
	c_path_to_archive = "archive";
	c_path_to_quarantine = "quarantine";

	c_db_name = "kc_smtp";
	c_db_root_name = "root";
	c_db_root_passwd = "root";

	cMaxSessions = 30;
	cMyDomain = "filtr.kc.smtp";
	cListenPort = 7777;
	cSslListenPort = 7778;
	cLogsFilepath = "logs.txt";
	cLogsLevel = All;
	cMaxMessageSize = 30000000; // w bitach
	cMode = Safe;
	cCheckAntivir = true;
	cSmtpServer = "smtp.gmail.com";
	cSmtpPort = 465;
}

// ----------------------------------------------------------- //

const std::string & Config::getPathToArchive() const
{
	return c_path_to_archive;
}

// ----------------------------------------------------------- //

const std::string & Config::getPathToQuarantine() const
{
	return c_path_to_quarantine;
}

// ----------------------------------------------------------- //

const std::string & Config::GetDatabaseName() const
{
	return c_db_name;
}

// ----------------------------------------------------------- //

const std::string & Config::getDatabaseRootName() const
{
	return c_db_root_name;
}

// ----------------------------------------------------------- //

const std::string & Config::getDatabaseRootPassword() const
{
	return c_db_root_passwd;
}

